QT             += core gui xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TEMPLATE        = lib
CONFIG         += plugin
INCLUDEPATH    += ../abhidhaana
HEADERS         = moniersedict.h
SOURCES         = moniersedict.cpp
TARGET          = $$qtLibraryTarget(moniersedict)

macx {
    DESTDIR         = ../dist/abhidhaana.app/Contents/MacOS/plugins
} else {
    DESTDIR         = ../dist/plugins
}

RESOURCES       += resource.qrc
OTHER_FILES     += moniersedict.json

INCLUDEPATH += ../libabhidhaana

unix {
    macx {
        CONFIG(debug, release|debug) {
            LIBS+= ../libabhidhaana/libabhidhaana_debug.a
        } else {
            LIBS += ../libabhidhaana/libabhidhaana.a
        }
    } else {
        LIBS += -L../libabhidhaana -labhidhaana
    }
}

win32 {
     CONFIG(debug, release|debug):LIBS+= ../libabhidhaana/debug/libabhidhaanad.a
     CONFIG(release, release|debug):LIBS+= ../libabhidhaana/release/libabhidhaana.a
}

#for build time running.
unix {
    macx {
        copyfiles.commands += mkdir -p ../dist/abhidhaana.app/Contents/MacOS/dict/monierse;
        copyfiles.commands += rm -rf ../dist/abhidhaana.app/Contents/MacOS/dict/monierse/*;
        copyfiles.commands += cp -rf $$PWD/dict/monierse/* ../dist/abhidhaana.app/Contents/MacOS/dict/monierse;
    } else {
        copyfiles.commands += mkdir -p ../dist/dict/monierse;
        copyfiles.commands += rm -rf ../dist/dict/monierse/*;
        copyfiles.commands += cp -rf $$PWD/dict/monierse/* ../dist/dict/monierse;
    }
}

win32 {
    WIN_PWD= $${PWD}
    WIN_PWD ~= s,/,\\,g
    copyfiles.commands += if not exist ..\\dist\\dict\\monierse md ..\\dist\\dict\\monierse &
    copyfiles.commands += if not exist ..\\dist\\dict\\monierse\\monier.xml copy $${WIN_PWD}\\dict\\monierse\\monier.xml ..\\dist\\dict\\monierse &
    copyfiles.commands += if not exist ..\\dist\\dict\\monierse\\monier.dtd copy $${WIN_PWD}\\dict\\monierse\\monier.dtd ..\\dist\\dict\\monierse &
    copyfiles.commands += if not exist ..\\dist\\dict\\monierse\\MWHeader.xml copy $${WIN_PWD}\\dict\\monierse\\MWHeader.xml ..\\dist\\dict\\monierse &
    copyfiles.commands += if not exist ..\\dist\\dict\\monierse\\README_FIRST.txt copy $${WIN_PWD}\\dict\\monierse\\README_FIRST.txt ..\\dist\\dict\\monierse &
}

QMAKE_EXTRA_TARGETS += copyfiles
POST_TARGETDEPS += copyfiles

unix {
  isEmpty(PREFIX) {
    PREFIX = /usr
  }
  BINDIR = $$PREFIX/share/abhidhaana
  DATADIR =$$PREFIX/share

  INSTALLS += target monierse 

  target.path =$$BINDIR/plugins

  monierse.path = $$DATADIR/abhidhaana/dict/monierse
  monierse.files += $$PWD/dict/monierse/README_FIRST.txt
  monierse.files += $$PWD/dict/monierse/monier.xml
  monierse.files += $$PWD/dict/monierse/monier.dtd
  monierse.files += $$PWD/dict/monierse/MWHeader.xml
}

